import request from '@/utils/request'
import { ObjectType, ResponseDataPromise } from 'typings/interfaces'
import * as proxy from '@/constants/proxy'
import { Pagination } from '@/components/Records/types'
export interface Params extends ObjectType {
  goodsType?: string
  goodsName?: string
}

export const fetchRecordsRequest = (
  pagination: Omit<Pagination, 'total'>,
  data: Params
): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-tunnel-in/page',
    method: 'post',
    data,
    params: Object.assign(pagination, data),
  })


export const createRecordRequest = (data: Params): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-tunnel-in',
    method: 'post',
    data,
  })


export const editRecordRequest = (data: Params): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-tunnel-in',
    method: 'patch',
    data,
  })

export const lockRecordRequest = (id: string, lock: '0' | '1') =>
  request({
    url: proxy.CHECC_API_BASE_DATA + `/bd-tunnel-in/lock`,
    method: 'post',
    data: {
      id,
      lock
    },
  })


export const deleteRecordsRequest = (ids: string[]) =>
  request({
    url: proxy.CHECC_API_BASE_DATA + `/bd-tunnel-in`,
    method: 'delete',
    data: ids
  })

// 通过id查询
export function queryTunnel(id: any) {
  return request({
    url: proxy.CHECC_API_BASE_DATA + `/bd-tunnel-in/${id}`,
    method: 'GET',
  })
}
export const exportRecordsRequest = (): ResponseDataPromise<ObjectType> =>
  request({
    url: proxy.CHECC_API_BASE_DATA + '/bd-tunnel-in/export',
    method: 'post',
  })

// 隧道概览信息
  export const tunnelRecordsRequest = (
    pagination: Omit<Pagination, 'total'>,
    data: Params
  ): ResponseDataPromise<ObjectType> =>
    request({
      url: proxy.CHECC_API_BASE_DATA + '/bd-tunnel-in/overview',
      method: 'post',
      data,
      params: Object.assign(pagination, data),
    })
